from tkinter import *
import tkinter.messagebox as messagebox
#实现图形化输出helloworld,并添加结束按钮
class Application(Frame):
    def __init__(self,master=None):
        Frame.__init__(self,master)
        self.pack()
        self.createWidgets()
    def createWidgets(self):
        self.helloLabel=Label(self,text='hello,world')
        self.helloLabel.pack()
        self.quitButton=Button(self,text='quit',command=self.quit)
        self.quitButton.pack()
#继承Application类，添加输入文本功能
class inputApplication(Application):
    def createWidgets(self):
        self.nameInput=Entry(self)
        self.nameInput.pack()
        self.alertButton=Button(self,text='hello',command=self.hello)
        self.alertButton.pack()
    def hello(self):
        name=self.nameInput.get() or 'world'
        messagebox.showinfo('Message','hello %s'%name)
'''
app=Application()
app.master.title('你好，画手')
app.mainloop()
'''
app=inputApplication()
app.master.title('你好，画手啊')
app.mainloop()